feat: add memory primitive#1096
Conversation
|
Issue: The PR description is empty — no description of the feature, no linked issue, no use cases, no API design rationale, and all checklist items are unchecked. Suggestion: This PR introduces a significant new public primitive (
This PR should also carry a |
|
Assessment: Request Changes This PR introduces a Review Themes
The core design is solid and the test coverage for direct method calls is thorough. Addressing the API design questions and adding tool integration tests would make this ready to merge. |
3df89c8 to
8e6239a
Compare
| * | ||
| * @param _agent - The agent to register hooks with | ||
| */ | ||
| initAgent(_agent: LocalAgent): void {} |
There was a problem hiding this comment.
Issue: Since initAgent is a no-op, MemoryManager only uses the getTools() extension point — which means it's functionally identical to passing it via plugins: [memoryManager]. The dedicated memoryManager config field on AgentConfig adds API surface without differentiated behavior.
Suggestion: Either:
- Add meaningful
initAgentbehavior (e.g., registering aBeforeModelCallEventhook to auto-inject relevant context from memory into the system prompt or messages), which would justify the dedicated field, OR - Remove the dedicated field for now and document
MemoryManageras a regular plugin (plugins: [new MemoryManager({...})]) until the feature is more mature. This keeps the Agent config surface minimal.
The session manager justifies its dedicated field because it registers multiple hooks in initAgent (AfterInvocation, MessageAdded, etc.). A parallel justification is needed here.
There was a problem hiding this comment.
initAgent will be used for injection (BeforeInvocationEvent), ingestion (AfterInvocationEvent), and eviction-triggered ingestion. These are planned for follow-up PRs.
|
Assessment: Request Changes The Review Categories
The underlying types ( |
8e6239a to
a364f6d
Compare
|
Assessment: Comment (prior "Request Changes" items are largely addressed) The author has addressed the majority of prior review feedback — Remaining Items
The implementation is solid and the author's reply about future |
a364f6d to
8fbe97d
Compare
|
Assessment: Comment The Remaining Items
Clean implementation that follows existing SDK patterns (Plugin interface, structured logging, barrel exports, co-located tests). |
|
Issue: This PR is 160 files changed (~5,655 insertions, ~14,699 deletions) bundling the new memory feature with multiple unrelated breaking changes:
Each of these is a breaking change that removes public API surface. Bundling them together makes it impossible to review the memory feature in isolation, creates a massive risk of merge conflicts, and makes it very difficult to revert any single change if issues arise. Suggestion: Split this into separate PRs:
If the removals are already planned/tracked elsewhere, rebase this branch to remove them from the diff. |
| throw new Error('MemoryManager: storeToolConfig targets no writable stores') | ||
| } | ||
|
|
||
| if (config.storeToolConfig === true && resolved.length > 1 && !toolConfig.stores) { |
There was a problem hiding this comment.
Issue: storeToolConfig: true enforces a safety check that throws when multiple writable stores exist (preventing ambiguous multi-store writes), but storeToolConfig: {} bypasses this check entirely — even though both represent "enable the store tool with defaults."
// This throws: "must specify `stores` when multiple writable stores"
new MemoryManager({ stores: [writableA, writableB], storeToolConfig: true })
// This silently writes to BOTH stores — no validation
new MemoryManager({ stores: [writableA, writableB], storeToolConfig: {} })The guard on line 82 checks config.storeToolConfig === true (strict equality), so the empty object escapes it.
Suggestion: Change the check to apply whenever toolConfig.stores is unspecified, regardless of whether the input was true or {}:
if (resolved.length > 1 && !toolConfig.stores) {
throw new Error(
'MemoryManager: storeToolConfig must specify `stores` when multiple writable stores are configured'
)
}This closes the escape hatch and makes the two equivalent inputs behave identically.
|
Assessment: Request Changes The memory feature itself is well-implemented and most prior feedback has been addressed. However, the PR bundles 160 files of unrelated breaking changes (interventions removal, tool-caller removal, limits removal, sandbox removal, renames) alongside the new feature, which should be split. Review Categories
The memory implementation itself (types, MemoryManager, tests) is clean and follows SDK patterns well. |
Description
Related Issues
Documentation PR
Type of Change
Bug fix
New feature
Breaking change
Documentation update
Other (please describe):
Testing
How have you tested the change?
npm run checkChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.